package person.tavion.transaction.produce;

import com.alibaba.fastjson2.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class UserTestService {
    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;


    @Transactional
    public String send(List<Map<String, Object>> list) {
        for (Map<String, Object> stringObjectMap : list) {
            kafkaTemplate.send("myTestUser","key", JSON.toJSONString(stringObjectMap));
        }
        return "true";
    }
}
